<!DOCTYPE html>
<script src="/resources/testharness.js"></script>
<script src="/resources/testdriver.js"></script>
<script src="/resources/testdriver-vendor.js"></script>
<script src="utils.js"></script>
<title>Fenced frame content to report the result of navigator.usb.requestDevice</title>

<body>
<script>
window.onload = () => {
  requestAnimationFrame(() => {
    simulateGesture(async function() {
      // This file is meant to be navigated to from a <fencedframe> element. It
      // reports back to the page hosting the <fencedframe> whether or not
      // `navigator.usb.requestDevice` is allowed.
      const usb_request_device_key = KEYS['usb.requestDevice'];
      try {
        await navigator.usb.requestDevice({ filters: [{ vendorId: 0 }] });
        writeValueToServer(usb_request_device_key, 'permission granted');
      } catch (e) {
        writeValueToServer(usb_request_device_key, `${e.name}: ${e.message}`);
      }
    });
  });
};
</script>
</body>
